// Angular Version 6 below need to be deleted {providedIn: 'root'}

// angular
import {Injectable} from '@angular/core';
import {HttpParams} from '@angular/common/http';
// owner
import {Request} from 'pengesoft-ng-lib';
// models
// import {any[]} from '../domains/any[].domain';

/**
 * JobServiceSvr
 */
@Injectable({
  providedIn: 'root'
})
export class JobServiceSvr {
  baseUrl: string;

  constructor(
    private request: Request
  ){
    this.baseUrl = 'JobServiceSvr.assx/';
  }

  /**
   *
   */
  getJobByDept(deptId: string): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('deptId', deptId.toString());
    return this.request.post<any[]>(this.baseUrl + 'getJobByDept', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  getAllJob(): Promise<any[]>{
    const httpParams = new HttpParams();
    return this.request.post<any[]>(this.baseUrl + 'getAllJob', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  delJob(jobId: string): Promise<number>{
    const httpParams = new HttpParams()
      .append('jobId', jobId.toString());
    return this.request.post<number>(this.baseUrl + 'delJob', httpParams).then((res) => {
      return res;
    });
  }

  /**
   * 
   */
  getAllJobDto(): Promise<any[]>{
    const httpParams = new HttpParams();
    return this.request.post<any[]>(this.baseUrl + 'getAllJobDto', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  GetVersion(): Promise<string>{
    const httpParams = new HttpParams();
    return this.request.post<string>(this.baseUrl + 'GetVersion', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  addJob(jobName: string, deptId: string, jobNum: string): Promise<number>{
    const httpParams = new HttpParams()
      .append('jobName', jobName.toString())
      .append('deptId', deptId.toString())
      .append('jobNum', jobNum.toString());
    return this.request.post<number>(this.baseUrl + 'addJob', httpParams).then((res) => {
      return res;
    });
  }

  myGetAllJobDto(): Promise<any[]>{
    const httpParams = new HttpParams();
    return this.request.post<any[]>(this.baseUrl + 'myGetAllJobDto', httpParams).then((res) => {
      return  res;
    });
  }
}
